# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Contributor: Dominic Meiser [git at msrd0 dot de]

pkgname=sqlx-cli
pkgver=0.6.3
pkgrel=1
pkgdesc='Command-line utility for SQLx, the Rust SQL toolkit'
license=('Apache' 'MIT')
arch=('loong64' 'x86_64')
url="https://github.com/launchbadge/sqlx"
depends=('gcc-libs' 'openssl')
makedepends=('rust')
source=("$pkgname-$pkgver.tar.gz::https://github.com/launchbadge/sqlx/archive/refs/tags/v${pkgver}.tar.gz")
sha512sums=('308410d5d9125d241e6141b254ba55dc964f3e9fcca0a4b0a9e26a96bad250c0c8e3400f7e689226f0558bfaaf04fb9ac450fc2abbb484ac94d615442b34429b')
options=('!lto')

build() {
    cd "sqlx-$pkgver/sqlx-cli"
    cargo build --locked --release
}

check() {
    cd "sqlx-$pkgver/sqlx-cli"
    cargo test --locked
}

package() {
    cd "sqlx-$pkgver"
    install -Dm755 "target/release/cargo-sqlx" "$pkgdir/usr/bin/cargo-sqlx"
    install -Dm755 "target/release/sqlx" "$pkgdir/usr/bin/sqlx"
    install -Dm644 LICENSE-APACHE "$pkgdir/usr/share/licenses/$pkgname/LICENSE-APACHE"
    install -Dm644 LICENSE-MIT "$pkgdir/usr/share/licenses/$pkgname/LICENSE-MIT"
}
